home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 October / Macworld (1998-10).dmg / Shareware World / Info / For Developers / MacZoop 1.8.4 / More Classes / Plug-In Classes / ZPlugIn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-03  |  2.0 KB  |  68 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            MacZoop - "the framework for the rest of us"         
  5. *
  6. *
  7. *
  8. *            ZPlugIn.h            -- a generic plug-in object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1997, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #pragma once
  22.  
  23. #ifndef __ZPLUGIN__
  24. #define    __ZPLUGIN__
  25.  
  26.  
  27. #include    "ZResourceFile.h"
  28. #include    "ZDefines.h"
  29.  
  30. // abstract class definition:
  31.  
  32. class    ZPlugIn    : public ZResourceFile
  33. {
  34. protected:
  35.     UniversalProcPtr    entryPointUPP;        // upp to plug-in code
  36.     Str255                plName;                // plug-in name
  37.  
  38. public:
  39.  
  40.     ZPlugIn( const FSSpec& plugFile ) : ZResourceFile( plugFile ) {};
  41.     ~ZPlugIn() {};
  42.     
  43.     virtual OSErr    InitPlugIn() { LoadPlugInCode(); return noErr; };
  44.     virtual OSErr    OpenPlugIn() { return noErr; };
  45.     virtual OSErr    CallPlugIn( const long message, void* msgData ) { return noErr; };
  46.     virtual OSErr    ClosePlugIn() { return noErr; };
  47.     
  48.     virtual void    GetName( Str255 aName ) { CopyPString( itsSpec.name, aName ); };
  49.  
  50. protected:
  51.  
  52.     virtual void    LoadPlugInCode() { entryPointUPP = NULL; };
  53. };
  54.  
  55. // This class is the basis for a plug-in architecture. Plug-Ins are based on resource files
  56. // so they can have their own resources. This class is an abstract base-class and the actual
  57. // implementation is left to your own subclasses. An associated object, ZPlugInHandler, is
  58. // responsible for gathering the available plug-ins into a list and passing messages to
  59. // them. You are responsible for establishing a common format and protocol for your plug-ins-
  60. // this class does not force you to use any particular arrangement, though you are expected
  61. // to set <entryPointUPP> to be a valid UPP to your plug-ins code.
  62.  
  63. // Note that building a plug-in architecture is quite an advanced topic, which is why you
  64. // don't get all that much help here. MacZoop provides a loose framework, but you'll need to
  65. // fill in pretty much all of the detail since plug-in schemes can vary widely.
  66.  
  67.  
  68. #endif